package xuecheng.tool.distributed.lock;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.integration.support.locks.LockRegistry;

/**
 * 分布式锁配置
 *
 * @author PengXueCheng
 */
@SpringBootConfiguration
public class CpxDistributedAutoConfig {

    /**
     * Redis提供分布式锁
     *
     * @param redisConnectionFactory
     * @return
     */
    @Bean
    public LockRegistry redisLockRegistry(RedisConnectionFactory redisConnectionFactory) {
        return new RedisLockRegistry(redisConnectionFactory, "redis_lock_registry::");
    }

}